package com.shop.servlet.model;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;


@Data
public class LoginUser implements UserDetails {
    private Long id;

    private String username;

    private String email;


    private String password;

    private Collection<? extends GrantedAuthority> authorities;
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;  // 账号未过期
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;  // 账号未锁定
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;  // 凭证未过期
    }

    @Override
    public boolean isEnabled() {
        return true;  // 账号启用
    }

    public LoginUser(Long id, String username, String email, String password) {
        this.id = id;
        this.username = username;
        this.email = email;
        this.password = password;
    }
}
